package com.atguigu.product.web;

import com.atguigu.product.service.SkuInfoService;
import com.atguigu.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

/**
 * description: ItemController商品详情
 * date: 2022/12/1 9:47
 * author: MR.孙
 */
@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;


    /**
     * 展示当前sku商品详情
     * @return
     */
    @RequestMapping("/{skuId}.html")
    public String skuItem(@PathVariable Long skuId, Model model) throws ExecutionException, InterruptedException {

        System.out.println("准备查询" + skuId + "详情");
        SkuItemVo skuItemVo= skuInfoService.item(skuId);
        model.addAttribute("item", skuItemVo);

        return "item";
    }

}
